package com.example.boot_mp.controller;


import com.example.boot_mp.entity.Books;
import com.example.boot_mp.mapper.BooksMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wm
 * @since 2024-09-03
 */
@RestController
@RequestMapping("/books")
public class BooksController {
    @Resource
    BooksMapper booksMapper;
    @RequestMapping("addBook")
    public String addBook(@RequestBody Books books){
        int insert = booksMapper.insert(books);
        return insert+"";
    }
    @RequestMapping("deleteBook")
    public String deleteBook(String bookid){
        int delete = booksMapper.deleteById(bookid);
        return delete +"";
    }

    @RequestMapping("updateBook")
    public String updateBook(@RequestBody Books books){
        int update = booksMapper.updateById(books);
        return update+"";
    }
    @RequestMapping("selectBook")
    public Books selectBook(String bookid){
        Books books = booksMapper.selectById(bookid);
        return books;
    }
}

